<?php
/**
 * Apc缓存驱动器
 *
 * @author Tongle Xu <xutongle@gmail.com> 2012-10-31
 * @copyright Copyright (c) 2003-2103 yuncms.net
 * @license http://leaps.yuncms.net
 * @version $Id: Apc.php 623 2013-07-29 03:40:03Z 85825770@qq.com $
 */
class Cache_Apc extends Cache {
	
	/**
	 * (non-PHPdoc)
	 *
	 * @see Cache::init()
	 */
	public function init() {
		parent::init ();
		if (! extension_loaded ( 'apc' )) throw new Exception ( 'ApcCache requires PHP apc extension to be loaded.' );
	}
	
	/**
	 * (non-PHPdoc)
	 *
	 * @see Cache::getValue()
	 */
	protected function getValue($key) {
		return apc_fetch ( $key );
	}
	
	/**
	 * (non-PHPdoc)
	 *
	 * @see Cache::getValues()
	 */
	protected function getValues($keys) {
		return apc_fetch ( $keys );
	}
	
	/**
	 * (non-PHPdoc)
	 *
	 * @see Cache::setValue()
	 */
	protected function setValue($key, $value, $expire) {
		return apc_store ( $key, $value, $expire );
	}
	
	/**
	 * (non-PHPdoc)
	 *
	 * @see Cache::addValue()
	 */
	protected function addValue($key, $value, $expire) {
		return apc_add ( $key, $value, $expire );
	}
	
	/**
	 * (non-PHPdoc)
	 *
	 * @see Cache::deleteValue()
	 */
	protected function deleteValue($key) {
		return apc_delete ( $key );
	}
	
	/**
	 * (non-PHPdoc)
	 *
	 * @see Cache::flushValues()
	 */
	protected function flushValues() {
		return apc_clear_cache ( 'user' );
	}
}